package yx.grpc.service;

import com.yx.grpc.user.*;
import io.grpc.stub.StreamObserver;
import net.devh.boot.grpc.server.service.GrpcService;
import yx.grpc.entiy.TblUser;

@GrpcService
public class UserServiceImpl  extends UserServiceGrpc.UserServiceImplBase{

    @Override
    public void queryUser(UserRequest request, StreamObserver<UserReply> responseObserver) {
        UserReply.Builder userReply =  UserReply.newBuilder();
        TblUser tblUser = new TblUser(11L, "syx", "nan");
        userReply.setCode(200).setMsg("SUCCESS").setSuccess(true);
        userReply.setData(UserReply.Data.newBuilder()
                .setUserPb(UserPb.newBuilder()
                        .setId(tblUser.getId())
                .setName(tblUser.getName())
                .setSex(tblUser.getSex())));
        responseObserver.onNext(userReply.build());
        responseObserver.onCompleted();
        super.queryUser(request, responseObserver);
    }
}
